package com.capital.controller;

import com.capital.entity.CfnInfo;
import com.capital.service.CfnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/")
public class CfnController {

	@Autowired
	private CfnService cfnService;

	@RequestMapping(value = "/testcfn", method = RequestMethod.POST)
	public String testCfn() {
		return cfnService.testCfn();
	}

	@RequestMapping(value = "/addcfn", method = RequestMethod.POST)
	public String addCfn(@RequestBody Map<String, Object> body) {
		return cfnService.addCfn(body).toString();
	}

	@RequestMapping(value = "/getcfnbyinfocode", method = RequestMethod.POST)
	public String getCfnByInfoCode(@RequestBody Map<String, Object> body) {
		return cfnService.getCfnByInfoCode((String)body.get("infoCode")).toString();
	}

	@RequestMapping(value = "/requestcfnfromeastmoney", method = RequestMethod.POST)
	public boolean addCfnFromEastmoney(@RequestBody Map<String, Object> body) {
		return cfnService.requestCfnFromEastmoney(body);
	}

	@RequestMapping(value = "/setcfndate", method = RequestMethod.POST)
	public String setCfnDate(@RequestBody Map<String, Object> body) {
		return cfnService.setCfnDate(body.get("value").toString());
	}

	@RequestMapping(value = "/getcfndate", method = RequestMethod.POST)
	public String setCfnDate() {
		return cfnService.getCfnDate();
	}

}
